package com.oneinlet

import org.junit.Test
import java.math.BigDecimal
import kotlin.collections.ArrayList

/**
 * Created by WangZiHe on 2018/5/13
 * QQ/WeChat:648830605
 * QQ-Group:368512253
 * Blog:www.520code.net
 * Github:https://github.com/yancheng199287
 */

class TestYCString {

    @Test
    fun testIsEmpty() {
        val name = ""
        val address = null
        val sex = 1
        println("我是一个空字符串吗？ ${YCString.isEmpty(name)}")
        println("我是一个null？ ${YCString.isEmpty(address)}")
        println("我是一个empty？ ${YCString.isEmpty(sex)}")
    }

    @Test
    fun testHasText() {
        val name = ""
        val address = "      武汉市"
        val sex = "男生"
        println("name 是否有内容？ ${YCString.hasText(name)}")
        println("address 是否有内容？ ${YCString.hasText(address)}")
        println("sex 是否有内容？ ${YCString.hasText(sex)}")
    }

    @Test
    fun testIsNotEmptyArray() {
        val b = YCString.isNotEmptyArray("人间值得", "不负岁月", "往事如风")
        println("支持多个字符串判空 b：$b")

        val b1 = YCString.isNotEmptyArray("人间值得", "不负岁月", "")
        println("支持多个字符串判空 b1：$b1")
    }

    @Test
    fun testIsEmptyArray() {
        val b = YCString.isEmptyArray("人间值得", "不负岁月", "往事如风")
        println("支持多个字符串判空 b：$b")

        val b1 = YCString.isEmptyArray("", null, "")
        println("支持多个字符串判空 b1：$b1")
    }

    @Test
    fun testHasLength() {
        // 注意空字符串的长度是0，hasLength方法是判断长大大于0的字符串
        val name = ""
        val address = "      武汉市"
        val sex = "男生"
        println("name 是否有内容？ ${YCString.hasLength(name)} ")
        println("address 是否有内容？ ${YCString.hasLength(address)}")
        println("sex 是否有内容？ ${YCString.hasLength(sex)}")
    }


    @Test
    fun testGenerateRandomNum() {
        for (i in 1..5) {
            println("第 $i 次 生成9位随机数字字符串${YCString.generateRandomNum(9)}")
        }

    }

    @Test
    fun testGenerateRandomChar() {
        for (i in 1..5) {
            println("第 $i 次 生成11位随机字符串${YCString.generateRandomChar(11)}")
        }
    }

    @Test
    fun testGenerateRandomLetter() {
        for (i in 1..5) {
            println("第 $i 次 生成11位大小写字母随机字符串${YCString.generateRandomLetter(11)}")
        }
    }

    @Test
    fun testGenerateRandomIntervalNum() {
        for (i in 1..15) {
            println("负数范围***** " + YCString.generateRandomIntervalNum(-3, 0))
            // println("正数数范围--- " + YCString.generateRandomIntervalNum(15, 20))
        }

    }

    @Test
    fun testToString() {
        val user = User()
        user.name = "上官婉儿"
        user.id = 100
        user.age = 19
        user.money = BigDecimal.valueOf(355555500.33)
        var list = ArrayList<ArrayList<String>>();
        var list1 = ArrayList<String>();
        list1.add("sssss");list1.add("sddddadasd");
        var list2 = ArrayList<String>();
        list2.add("asdadasdadas");list2.add("52465456")

        list.add(list1)
        list.add(list2)

        //_支持嵌套
        user.list = list
        println(YCString.toString(user))

    }

    @Test
    fun testJoinString() {
        val delimiter = "|"
        val list = arrayListOf("55", "66", "77", "88")
        val list1 = arrayOf("aa", "bb", "cc", "dd")
        println(YCString.join(delimiter, *list.toTypedArray()))
        println(YCString.join(delimiter, *list1))
        println(YCString.join(delimiter, "xx", "yy", "zz"))
    }


}